﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using HCMServices.DAO;
using HCMServices.DTO;
using System.Collections.Generic;

namespace HCMServices.Tests.TESTDAO
{
    /// <summary>
    /// Unit test for DistrictDAO class
    /// </summary>
    [TestClass]
    public class TestDistrictDAO
    {
        /// <summary>
        /// Unit test for Search() method in DistrictDAO class
        /// </summary>
        [TestMethod]
        public void TestSearch()
        {
            string connectString = "Data Source = isostore:/Database.sdf";

            DistrictDAO districtDao = new DistrictDAO(connectString);
            DistrictDTO districtDTO = null;
            districtDTO = districtDao.Search(26);
            if (districtDTO != null && districtDTO.Id == 26 && districtDTO.Name == "1")
            {
                Assert.IsTrue(true);
                return;
            }

            Assert.IsFalse(true);
        }

        /// <summary>
        /// Unit test for GetAllQuanHuyenDTO() method in DistrictDAO class
        /// </summary>
        [TestMethod]
        public void TestGetAllQuanHuyenDTO()
        {
            string connectString = "Data Source = isostore:/Database.sdf";

            DistrictDAO districtDao = new DistrictDAO(connectString);
            List<DistrictDTO> listDistrictDTO = null;
            listDistrictDTO = districtDao.GetAllQuanHuyenDTO();
            if (listDistrictDTO == null || listDistrictDTO.Count == 0)
            {
                Assert.IsFalse(true);
            }

            foreach (DistrictDTO district in listDistrictDTO)
            {
                if (district.Name == "1")
                {
                    if (district.Id != 26)
                    {
                        Assert.IsFalse(true);
                    }
                }
            }

            Assert.IsTrue(true);
        }

        /// <summary>
        /// Unit test for TestGetIdByName() method in DistrictDAO class
        /// </summary>
        [TestMethod]
        public void TestGetIdByName()
        {
            string connectString = "Data Source = isostore:/Database.sdf";

            DistrictDAO districtDao = new DistrictDAO(connectString);
            int id = districtDao.GetIdByName("1");
            if (id == 26)
            {
                Assert.IsTrue(true);
                return;
            }

            Assert.IsFalse(true);
        }
    }
}
